<?php header("Content-type:text/xml");?>
<?php echo "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>";?>

<netcuberesult>
<?php require_once(dirname(__FILE__)."/../config/config.php"); ?>
<?php
$username = $_GET['username'];
$password=$_GET['password'];
$sql = "select * from zy_user where user_name = '".$username."' and password='".$password."'";
$result = mysql_query($sql);
$rs = mysql_fetch_array($result);
if($rs!=""){
    $sql2 = "select * from zy_group where user_id = '".$rs['user_id']."'";
    $result2=mysql_query($sql2);
    $rs2=mysql_fetch_array($result2);
}
if($rs2==""){?>
<error><?php if($rs==""){echo "The username or password is wrong!";}else{ echo "The user have no group!";}?></error>
<?php }?>
<?php
    if($rs!=""){
        $sql2 = "select * from zy_group where user_id = '".$rs['user_id']."'";
        $result2 = mysql_query($sql2);
        while($rs2=mysql_fetch_array($result2)){
            $name = $rs2['name'];
?>
    <?php  $sql4="select * from zy_contact where group_id ='".$rs2['id']."'";
            $result4=mysql_query($sql4);
            $rs4=mysql_fetch_array($result4);
            if($rs4!=""){
?>
    <group name="<?php echo $name; ?>">
            <?php  $sql3="select * from zy_contact where group_id ='".$rs2['id']."'";
            $result3=mysql_query($sql3);
            while($rs3=mysql_fetch_array($result3)){ ?>
            <name><?php echo $rs3['name'];?></name>
            <nickname><?php echo $rs3['nickname'];?></nickname>
            <address1><?php echo $rs3['address1']; ?></address1>
             <address2><?php echo $rs3['address2']; ?></address2>
             <phone1><?php echo $rs3['phone1']; ?></phone1>
             <phone2><?php echo $rs3['phone2']; ?></phone2>
             <fax1><?php echo $rs3['fax1']; ?></fax1>
            <fax2><?php echo $rs3['fax2'];?></fax2>
            <remark><?php echo $rs3['remark'];?></remark>
            <?php } ?>
            </group>
<?php
            }
        }
    }
?>
</netcuberesult>



